package fi.softala.multiplikation;

import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

		SharedPreferences scores = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

		try {
			String onKaynnistetty = scores.getString("onkaynnistetty", null);
		} catch (Exception ex) {
			SharedPreferences.Editor editor = scores.edit();
			editor.putString("score1", "aku 199");
			editor.putString("score2", "aku 199");
			editor.putString("score3", "aku 199");
			editor.putString("onkaynnistetty", "1");
			editor.commit();
		}

		/*
		 * Button btAsetaKoulu = (Button) findViewById(R.id.btAsetaKoulu);
		 * btAsetaKoulu.setOnClickListener(new OnClickListener() {
		 * 
		 * @Override public void onClick(View v) { //
		 * showToast("Klikattiin Configurea!"); Intent seuraavaIntent = new
		 * Intent(MainActivity.this, KouluValintaActivity.class);
		 * startActivity(seuraavaIntent); } });
		 */
		Button btVaikea = (Button) findViewById(R.id.btVaikea);
		btVaikea.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				// showToast("Klikattiin Configurea!");
				Intent seuraavaIntent = new Intent(MainActivity.this,
						VaikeaActivity.class);
				startActivity(seuraavaIntent);
			}
		});



	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}

	public void showToast(String toastText) {
		Context context = getApplicationContext();
		int duration = Toast.LENGTH_LONG;
		Toast toast = Toast.makeText(context, toastText, duration);
		toast.show();
	}

	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		System.exit(0);
	}

}
